package com.mydesignpattern.beijing.responsibilitychain.simple;

import com.mydesignpattern.beijing.responsibilitychain.simple.impl.FaceFilter;
import com.mydesignpattern.beijing.responsibilitychain.simple.impl.HtmlFilter;
import com.mydesignpattern.beijing.responsibilitychain.simple.impl.SensitiveFilter;
import org.junit.jupiter.api.Test;

/**
 * 责任链测试类
 */
public class ChainTest {

    @Test
    public void mytest(){
        //论坛留言内容
        String msg = "楼主不懂就不要瞎说，世界就是有sb存在，来段脚本<script>alert(user.password)</script>,看能否生效，/haha";

        FilterChain chain = new FilterChain()
                .addFilter(new FaceFilter())
                .addFilter(new HtmlFilter())
                .addFilter(new SensitiveFilter());

        //给客户端使用的processor
        MsgProcessor processor = new MsgProcessor();
        processor.setFilterChain(chain);
        processor.setMsg(msg);

        //处理之后的结果
        String result = processor.processor(msg);
        System.out.println("========="+result);
    }




}
